<div class="data-table table-striped">
    <form class="ids">
        <table>
            <thead>
            <tr>
                <th>ID</th>
                <th>车系名称</th>
                <th>类型</th>
                <th>描述</th>
                <th>销售状态</th>
                <th>拼音</th>
                <th>状态</th>
                <th style="width:200px;text-align:center;">操作</th>
            </tr>
            </thead>
            <tbody id="trlist">
                <php>foreach($list AS $val):</php>
                <tr>
                    <td>{$val.series_id}</td>
                    <td style="float:left">{$val.name}</td>
                    <td><php>echo C('CAR_TYPE.'.$val['type']);</php></td>
                    <td>{$val.describe}</td>
                    <td><php>echo C('CAR_MODEL_SALE_STATUS.'.$val['sale_status']);</php></td>
                    <td>{$val.spell}</td>
                    <td id="status_cn{$val.series_id}"><if condition="$val[status] eq 0">启用<else/>禁用</if></td>
                    <td style="width:200px;text-align:center;">
                        <if condition="$can_manage">
                            <php> if($val['status'] >-1):</php>
                                <a title="编辑" href="javascript:edit('{$val.series_id}');">编辑</a>  &nbsp;
                                <if condition="$val['status'] gt 0">
                                    <a id="status{$val.series_id}" href="javascript:toggle('{$val.series_id}');">启用</a>  &nbsp;
                                <else/>
                                    <a id="status{$val.series_id}" href="javascript:toggle('{$val.series_id}');">禁用</a>  &nbsp;
                                </if>
                                <!--<a class="confirm ajax-get" href="javascript:del('{$val.series_id}');">删除</a>-->
                            <php>endif;</php>
                        </if>
                    </td>
                </tr>
                <php>endforeach;</php>
            </tbody>
        </table>
    </form>
</div>
<div class="pageFaye"><div class="pager">{$page}</div> <div class="clear"></div></div>
<input type="hidden" name="p" value="{$p}">
<input type="hidden" name="char" value="{$curr_char}">
<input type="hidden" name="old_name_series" value="">
<input type="hidden" name="series_id" value="">

<script>
    function toggle(id){
        var type = 1;
        if($('#status'+id).html()=='禁用'){
            type = 1;
        }else{
            type = 0;
        }
        $.post("/CarModel/toggle/",{'id':id,'table':'series','type':type}, function (data) {
            if(data.code=='200'){
                if($('#status'+id).html()=='禁用'){
                    $('#status'+id).html('启用')
                    $('#status_cn'+id).html('禁用')
                }else{
                    $('#status'+id).html('禁用')
                    $('#status_cn'+id).html('启用')
                }
            }else{
                shibai_alert(data.msg)
            }
        }, "json");
    }

    function edit(id){
        $(".master_brand_alert").eq(2).fadeIn();
        $(".yunBei").show();
        //
        $.get("/CarModel/base_info/",{'id':id,'type':'series'}, function (data) {
            //主品牌首字母确定
            $('#first_char_series').val(data.data.first_char)

            //初始化主品牌下拉菜单
            $.ajaxSetup({ async: false });
            getBrand('master_id_series');
            $('#master_id_series').val(data.data.mbrand_id);

            //初始化品牌下拉菜单
            getBrand('brand_id_series','brand',data.data.mbrand_id);
            $('#brand_id_series').val(data.data.brand_id);
            $.ajaxSetup({ async: true });

            $('#sale_status').val(data.data.sale_status);
            $('#type').val(data.data.type);

            $('input[name=name_series]').val(data.data.name);
            $('input[name=old_name_series]').val(data.data.name);
            $('input[name=spell]').val(data.data.spell);
            $('input[name=desc]').val(data.data.describe);
            $('#status').val(data.data.status);

            $('input[name=series_id]').val(id);

        },'json')
    }
    function del(id){
        confirm_alert('<div style="color:red">确认移除该车系？</div>', confirm);
        function confirm() {
            $('.determine').click(function () {
                colse_hide();
                remove(id);
            });
        }
    }

    function remove(id){
        $.post("/CarModel/remove/",{'id':id,'type':'series'}, function (data) {
            if(data.code=='200'){
                btn_alert(data.msg);
            }else{
                shibai_alert(data.msg);
            }
        }, "json");
    }


</script>